module struct_demo(); 
    // Packed Struct: 可综合
    // 压缩结构体被视为单个向量
    typedef struct packed {
        logic [7:0] data;
        logic [7:0] addr;
    } pks_t;

    // Unpacked Struct: 不可综合
    typedef struct {
        logic [7:0] data;
        logic [7:0] addr;
    } upks_t;

initial begin
    begin
        // packed struct
        pks_t pks = 16'hAA_BB;
        $display("pks: %p", pks);
        pks = '{8'hCC, 8'hDD};
        $display("pks: %p", pks);
        pks = '{data: 8'hEE, addr: 8'hFF};
        $display("pks: %p", pks);
        pks.data = 8'h11;
        pks.addr = 8'h22;
        $display("pks: %p", pks);

    end

    begin
        // unpacked struct
        upks_t upks = '{8'hAA, 8'hBB};
        $display("upks: %p", upks);
        upks = '{data: 8'hCC, addr: 8'hDD};
        $display("upks: %p", upks);
        upks.data = 8'hEE;
        upks.addr = 8'hFF;
        $display("upks: %p", upks);
    end

end

endmodule 
